<template>
  <div class="form-layout">
    <!--左侧导航-->
    <div class="nav-left">
      <customAnchor :itemList="[
        { name: 'box-base', title: '基础信息' },
        { name: 'box-manage', title: '运行配置' },
        { name: 'box-base2', title: '登记信息' },
        { name: 'box-location', title: '位置信息' },
        { name: 'box-contact', title: '联系信息' },
        { name: 'box-invoice', title: '发票抬头' }]" />
    </div>
    <!--表单区域-->
    <div class="form-right" ref="formRight">
      <customForm :data="form" :rules="propRules" ref="editForm" :disabled="propReadonly">
        <template #content>
          <div id="box-base" class="box-title">基础信息</div>
          <customFormItem label="医院名称" name="name" :parent="_self" :form="form" />
          <customFormItem  label="登录账号" name="loginKey"
                           :disabled="form.id"
                           :parent="_self" :form="form" />
          <customFormItem label="医院别名" name="otherNames" :parent="_self" :form="form" />
          <customFormItem label="组织代码" name="oid"
                          :parent="_self" :form="form"
                          :disabled="!form.id"
          />
          <customFormItem label="系统编码" name="code"
                          :parent="_self" :form="form"
                          :config="{ defaultValue: '自动获取'}"
                          disabled />


          <customFormItem label="拼音" name="pinyin" :parent="_self" :form="form" />

          <customFormItem label="医院级别" name="hospitalLevel" :parent="_self" :form="form"
                          :type="constCommon.formItemType.selectDict.name"
                          :config="{dictType: constCommon.dictType.hospitalLevel}" />
          <customFormItem label="医院类型" name="hospitalType" :parent="_self" :form="form"
                          :type="constCommon.formItemType.selectDict.name"
                          :config="{dictType: constCommon.dictType.hospitalType}" />
          <customFormItem label="医院性质" name="hospitalCharacter" :parent="_self" :form="form"
                          :type="constCommon.formItemType.selectDict.name"
                          :config="{dictType: constCommon.dictType.hospitalCharacter}" />

          <customFormItem label="床位数量" name="bedNum" :parent="_self" :form="form"
                          :type="constCommon.formItemType.inputNumber.name" />
          <customFormItem label="临床科室数量" name="deptNum" :parent="_self" :form="form"
                          :type="constCommon.formItemType.inputNumber.name" />
          <customFormItem label="医护人员数量" name="staffNum" :parent="_self" :form="form"
                          :type="constCommon.formItemType.inputNumber.name"/>
          <customFormItem label="年门诊量(人次)" name="clinicYear" :parent="_self" :form="form"
                          :type="constCommon.formItemType.inputNumber.name"/>
          <customFormItem label="年手术量(场次)" name="operationYear" :parent="_self" :form="form"
                          :type="constCommon.formItemType.inputNumber.name"/>
          <customFormItem label="年耗材用量(万元)" name="matrUseYear" :parent="_self" :form="form"
                          :type="constCommon.formItemType.inputNumber.name" />

          <div id="box-manage" class="box-title">运行配置</div>
          <customFormItem label="禁止新增订单" name="flagDisabledOrderAdd" :parent="_self" :form="form"
              :type="constCommon.formItemType.switch.name"
              help="选中后,订单新增时该医院不可选择"
          />
          <customFormItem label="启用商品编辑" name="flagEnabledMaterialEdit" :parent="_self" :form="form"
              :type="constCommon.formItemType.switch.name"
              help="启用后,该医院的供货商品可以由供应商进行修改"
          />
          <customFormItem label="启用说明" name="enabledMaterialEditRemark" :parent="_self" :form="form"
              help="启用后,在编辑页面给供应商显示的提示信息"
              full-width
          />

          <div id="box-base2" class="box-title">登记信息</div>
          <customFormItem label="登记号" name="certificateNo" :parent="_self" :form="form" />

          <customFormItem label="登记开始" name="expStart"
                          :parent="_self" :form="form"
                          :type="constCommon.formItemType.datePicker.name" />

          <customFormItem label="登记截止" name="expEnd"
                          :parent="_self" :form="form"
                          :type="constCommon.formItemType.datePicker.name" />

          <customFormItem label="发证机关" name="certificateOffice" :parent="_self" :form="form" />


          <div id="box-location" class="box-title">位置信息</div>
          <customFormItem label="所在区域" name="regionName" :parent="_self" :form="form" />
          <customFormItem label="医院地址" name="address" :parent="_self" :form="form" />
          <customFormItem label="占地面积(亩)" name="area" :parent="_self" :form="form"
                          :type="constCommon.formItemType.inputNumber.name" />
          <customFormItem label="建筑面积(平方米)" name="floorage" :parent="_self" :form="form"
                          :type="constCommon.formItemType.inputNumber.name" />
          <customFormItem
            label="医院照片"
            name="hospitalImg"
            :parent="_self"
            :form="form"
            :type="constCommon.formItemType.slot.name"
            fullWidth
          >
            <template #content>
              <customUpload
                :data="{ fileRefId: form.id, fileRefTable: 'hospital', fileSavePath: 'hospital'}"
                :max="20"
                :disabled="propReadonly"
                multiple
                :hide="strings.isBlank(form.id)"
                hideMsg="请先保存主单据后再上传"
              />
            </template>
          </customFormItem>

          <div id="box-contact" class="box-title">联系信息</div>
          <customFormItem label="联系人" name="contactor" :parent="_self" :form="form" />
          <customFormItem label="手机号" name="mobile" :parent="_self" :form="form" />
          <customFormItem label="座机号码" name="phone" :parent="_self" :form="form" />
          <customFormItem label="邮箱" name="email" :parent="_self" :form="form" />

          <div id="box-invoice" class="box-title">发票抬头</div>
          <customFormItem label="名称" name="invoiceName" :parent="_self" :form="form" />
          <customFormItem label="税号" name="invoiceNo" :parent="_self" :form="form" />
          <customFormItem label="单位地址" name="invoiceAddress" :parent="_self" :form="form" />
          <customFormItem label="电话号码" name="invoiceTel" :parent="_self" :form="form" />
          <customFormItem label="开户银行" name="invoiceBankName" :parent="_self" :form="form" />
          <customFormItem label="银行账号" name="invoiceBankNo" :parent="_self" :form="form" />
        </template>
      </customForm>
    </div>
  </div>
</template>

<script>
import customAnchor from '@/components/custom/form/customAnchor.vue'
import customUpload from '@/components/custom/form/customUpload.vue'

export default {
  help: '医院管理-详情',
  data() {
    return {
      form: {},
      viewData: {},
    }
  },
  methods: {
    // 当前登录医院信息
    getCurrentHospital(id) {
      this.$ajax.get(`/base/hospitals/get_current_hospital`).then((response) => {
        if (response.code == 0) {
          this.form = response.data
        }
      })
    }
  },
  created() {
    this.$emit('event-register', {
      validate: (callback) => {
        return this.$refs.editForm.validate(callback)
      },
      beforeSave: () => {
        this.$emit('data-callback', this.form)
        return true
      },
      afterMove: (formData) => {
        this.form = global.utils.jsonClone(formData)
        this.$set(this.form, 'id', this.form.id)
      },
      afterSave: () => {
      },
      beforeDelete: () => {
        return true
      },
      afterDelete: () => {
      },
      beforeFlow: (flowButtonKey) => {
        return true
      },
      afterFlow: (flowButtonKey) => {
      },
      beforeClose: () => {
        return true
      },
    })
  },
  props: {
    propParent: Object,
    propInitData: Object,
    propPrimaryKey: String,
    propDictionaries: Object,
    propCurrentRow: Object,
    propViewFormData: Object,
    propReadonly: Boolean,
    propStatus: String,
    propRules: Object,
  },
  components: { customAnchor, customUpload },
  computed: {},
}
</script>
